/**
 * 
 */

//初始化页面加载
$(function(){
	pageList();
});

function pageList(){
	
	$.ajax({
		url : "../self/linkOkr",
		type : "post",
		dataType : "json",
		data : {"uniqueCode":uniqueCode},
		success : function(data){
			
			console.log(data);
			
			$("#parent_info").html("");
			$("#self_info").html("");
			$("#child_info").html("");
			
			var noMsg = '<div class="mui-card" style=""><div class="mui-card-footer"><p class="index-status" style="text-align:center; width:100%;margin-top:3%;">暂无信息</p></center></div>';
			
			if(data.self != null && data.self != ""){
				var html = appendHtml("s",data.self);
				$("#self_info").html(html);
			}
			
			if(data.parent != null && data.parent != ""){
				var html = appendHtml("p",data.parent);
				$("#parent_info").html(html);
			}else{
				//$("#parent_div").hide();
				$("#parent_info").html(noMsg);
			}
			
			if(data.child != null && data.child != "" && data.child.length > 0){
				var html = "";
				$.each(data.child,function(n,value) {
					html += appendHtml(n,value);
				});  
				$("#child_info").html(html);
			}else{
				//$("#child_div").hide();
				$("#child_info").html(noMsg);
			}
		}
	});
}


function appendHtml(n,value){
	var str ='';
	str += '<div class="mui-card" style="">';
	str += '<div class="noba">';
	str += '<div class="mui-card-header" style="border-tottom: none; padding-bottom: 0px;">';
	str += '<span style="float: left;"> <span class="bold">'+value.PERSON_LIABLE_NAME+'</span>';
	str += '&nbsp;&nbsp;&nbsp; <font color="#666666">'+okrTime(value.O_YEAR,value.O_QUARTER,value.O_MONTH)+'</font>';
	str += '</span> <span> <a href="#pop'+n+'"" class="mui-btn mui-btn-primary index-btn-mod"> ';
	str += '<span class="index-func mui-icon mui-icon-gear cfff"></span>';
	str += '</a></span></div>';
	str += '<div class="noba">';
	str += '<div class="mui-card-footer" style="border-top: solid thin #fff; padding-top: 0px; padding-bottom: 2px;">';
	str += '<span style="float: left; color: #6d6d72;">OKR类别：'+oTeam(value.OKR_TYPE)+'</span> <span>所属组织：'+value.OWNER_DEPTNAME+'</span>';
	str += '</div> </div>';
	str += '<div class="mui-card-footer" style="border-bottom: solid thin #ddd; border-top: solid thin #fff; padding-top: 0px; padding-bottom: 2px;">';
	str += '<span style="float: left; color: #6d6d72;">所属团队：'+value.OWNER_TEAMNAME+'</span> <span>职务：'+value.PERSON_LIABLE_POSTNAME+'</span>';
	str += '</div> </div>';
	str += '<div class="mui-card-content">';
	str += '<div class="mui-card-header">';
	str += '<span style="font-weight: bold;">'+value.O_CODE+'</span> ';
	str += '<span style="float: right; font-size: 14px; color: #666;"> ';
	str += '<span class="index-dlink"><a href="../self/krview?uniqueCode='+value.O_UNIQUE_ID_CODE+'">OKR详情</a></span></span>';
	str += '</div> <a href="../self/krview?uniqueCode='+value.O_UNIQUE_ID_CODE+'">';
	str += '<div class="mui-card-content-inner">';
	str += '<p class="index-o-de" style="margin-bottom: 0;">';
	str += '<span style="color: #007aff">定义：</span>' + value.O_DEFINITION;
	str += '</p></div></a></div>';
	str += '<div class="mui-card-footer">';
	str += '<span class="index-status">状态： <span class="index-shenhe">'+oState(value.O_STATE)+'</span>';
	str += '</span> <a href="pingfeno.php"><span>评分：'+oColor(value.O_SCORE_SUPERIOR)+'</span></a>';
	str += '</div><div class="mui-card-footer">';
	str += '<a href="../self/version?uniqueCode='+value.O_UNIQUE_ID_CODE+'">版本号：'+value.VERSION_CODE+' &nbsp;</a> <span style="float: right;">发布时间：'+getTime(value.DELIVERY_TIME)+'</span>';
	str += '</div></div><div id="pop'+n+'" class="mui-popover">';
	str += '<ul class="mui-table-view">';
	str += '<li class="mui-table-view-cell"><center>';
	str += '<a href="review?uniqueCode='+value.O_UNIQUE_ID_CODE+'">过程Review</a>';
	str += '</center></li>';
	str += '<li class="mui-table-view-cell"><center>';
	str += '<a href="../self/score?uniqueCode='+value.O_UNIQUE_ID_CODE+'">评分与总结</a>';
	str += '</center></li>';
	str += '<li class="mui-table-view-cell"><center>';
	str += '<a href="../self/version?uniqueCode='+value.O_UNIQUE_ID_CODE+'">版本信息</a>';
	str += '</center></li>';
	str += '<li class="mui-table-view-cell"><center>';
	str += '<a href="../self/link?uniqueCode='+value.O_UNIQUE_ID_CODE+'">关联OKR</a>';
	str += '</center></li></ul></div>';
	
	return str;
}
